package com.ruoyi.eqmonitor.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.eqmonitor.vo.CockpitInfoVo;
import com.ruoyi.eqmonitor.dtos.CockpitRiverwayAlarmDto;
import com.ruoyi.eqmonitor.service.CockpitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * 避免依赖循环
 */
@Slf4j
@Api(tags = "BI模块")
@RestController
@RequestMapping("/cockpit")
public class CockpitController extends BaseController {

    @Resource
    private CockpitService cockpitService;

    /**
     * 零直排驾驶舱——河道预警信息
     */
    @ApiOperation("零直排驾驶舱——河道预警信息")
    @GetMapping("/cockpitRiverwayAlarm")
    public TableDataInfo<?> cockpitRiverwayAlarm(CockpitRiverwayAlarmDto dto) throws ParseException {
        startPage();
        return getDataTable(cockpitService.cockpitRiverwayAlarm(dto));
    }

    /**
     * 查询断面、排口、溢流井的巡查上报事件相关数据
     * @param id 断面 或 排口 或 溢流井id
     * @param alarmType 类型（断面 或 排口 或 溢流井）
     */
    @ApiOperation("查询详细信息")
    @GetMapping("/{id}/{alarmType}")
    public AjaxResult getInfo(@PathVariable("id") Long id, @PathVariable("alarmType") Integer alarmType) throws ParseException {
        CockpitInfoVo info = cockpitService.getInfo(id, alarmType);
        return AjaxResult.success(info.getBusinessId());
    }

    /**
     * 管网一张图-项目总览右侧树各设备数量统计
     * @param name 街道名称
     */
    @ApiOperation("各设备数量统计")
    @GetMapping("/selectCount")
    public AjaxResult selectCount(String name){
        return AjaxResult.success(cockpitService.selectCount(name));
    }

}
